<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>elasticsearch-users | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'users-command.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/users-command.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/users-command.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/users-command.html" rel="nofollow" target="_blank">../en/users-command.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="commands.html">Command line tools</a></span>
»
<span class="breadcrumb-node">elasticsearch-users</span>
</div>
<div class="navheader">
<span class="prev">
<a href="syskeygen.html">« elasticsearch-syskeygen</a>
</span>
<span class="next">
<a href="how-to.html">How To »</a>
</span>
</div>
<div class="chapter xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="users-command"></a>elasticsearch-users<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/commands/users-command.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>If you use file-based user authentication, the <code class="literal">elasticsearch-users</code> command
enables you to add and remove users, assign user roles, and manage passwords.</p>
<h3>
<a id="_synopsis_10"></a>Synopsis<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/commands/users-command.asciidoc">edit</a>
</h3>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">bin/elasticsearch-users
([useradd &lt;username&gt;] [-p &lt;password&gt;] [-r &lt;roles&gt;]) |
([list] &lt;username&gt;) |
([passwd &lt;username&gt;] [-p &lt;password&gt;]) |
([roles &lt;username&gt;] [-a &lt;roles&gt;] [-r &lt;roles&gt;]) |
([userdel &lt;username&gt;])</pre>
</div>
<h3>
<a id="_description_10"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/commands/users-command.asciidoc">edit</a>
</h3>
<p>If you use the built-in <code class="literal">file</code> internal realm, users are defined in local files
on each node in the cluster.</p>
<p>Usernames and roles must be at least 1 and no more than 1024 characters. They
can contain alphanumeric characters (<code class="literal">a-z</code>, <code class="literal">A-Z</code>, <code class="literal">0-9</code>), spaces, punctuation,
and printable symbols in the
<a href="https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)" class="ulink" target="_top">Basic Latin (ASCII) block</a>.
Leading or trailing whitespace is not allowed.</p>
<p>Passwords must be at least 6 characters long.</p>
<p>For more information, see <a class="xref" href="file-realm.html" title="File-based user authentication">File-based user authentication</a>.</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>To ensure that Elasticsearch can read the user and role information at startup, run
<code class="literal">elasticsearch-users useradd</code> as the same user you use to run Elasticsearch. Running the
command as root or some other user updates the permissions for the <code class="literal">users</code> and
<code class="literal">users_roles</code> files and prevents Elasticsearch from accessing them.</p>
</div>
</div>
<h3>
<a id="_parameters_13"></a>Parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/commands/users-command.asciidoc">edit</a>
</h3>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">-a &lt;roles&gt;</code>
</span>
</dt>
<dd>
If used with the <code class="literal">roles</code> parameter, adds a comma-separated list
of roles to a user.
</dd>
</dl>
</div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">list</code>
</span>
</dt>
<dd>
List the users that are registered with the <code class="literal">file</code> realm
on the local node. If you also specify a user name, the command provides
information for that user.
</dd>
<dt>
<span class="term">
<code class="literal">-p &lt;password&gt;</code>
</span>
</dt>
<dd>
<p>
Specifies the user’s password. If you do not specify this
parameter, the command prompts you for the password.
</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>Omit the <code class="literal">-p</code> option to keep
plaintext passwords out of the terminal session’s command history.</p>
</div>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">passwd &lt;username&gt;</code>
</span>
</dt>
<dd>
Resets a user’s password. You can specify the new
password directly with the <code class="literal">-p</code> parameter.
</dd>
<dt>
<span class="term">
<code class="literal">-r &lt;roles&gt;</code>
</span>
</dt>
<dd>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
If used with the <code class="literal">useradd</code> parameter, defines a user’s roles. This option
accepts a comma-separated list of role names to assign to the user.
</li>
<li class="listitem">
If used with the <code class="literal">roles</code> parameter, removes a comma-separated list of roles
from a user.
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">roles</code>
</span>
</dt>
<dd>
Manages the roles of a particular user. You can combine adding and
removing roles within the same command to change a user’s roles.
</dd>
</dl>
</div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">useradd &lt;username&gt;</code>
</span>
</dt>
<dd>
Adds a user to your local node.
</dd>
<dt>
<span class="term">
<code class="literal">userdel &lt;username&gt;</code>
</span>
</dt>
<dd>
Deletes a user from your local node.
</dd>
</dl>
</div>
<h3>
<a id="_examples_12"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/commands/users-command.asciidoc">edit</a>
</h3>
<p>The following example adds a new user named <code class="literal">jacknich</code> to the <code class="literal">file</code> realm. The
password for this user is <code class="literal">theshining</code>, and this user is associated with the
<code class="literal">network</code> and <code class="literal">monitoring</code> roles.</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">bin/elasticsearch-users useradd jacknich -p theshining -r network,monitoring</pre>
</div>
<p>The following example lists the users that are registered with the <code class="literal">file</code> realm
on the local node:</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">bin/elasticsearch-users list
rdeniro        : admin
alpacino       : power_user
jacknich       : monitoring,network</pre>
</div>
<p>Users are in the left-hand column and their corresponding roles are listed in
the right-hand column.</p>
<p>The following example resets the <code class="literal">jacknich</code> user’s password:</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">bin/elasticsearch-users passwd jachnich</pre>
</div>
<p>Since the <code class="literal">-p</code> parameter was omitted, the command prompts you to enter and
confirm a password in interactive mode.</p>
<p>The following example removes the <code class="literal">network</code> and <code class="literal">monitoring</code> roles from the
<code class="literal">jacknich</code> user and adds the <code class="literal">user</code> role:</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">bin/elasticsearch-users roles jacknich -r network,monitoring -a user</pre>
</div>
<p>The following example deletes the <code class="literal">jacknich</code> user:</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">bin/elasticsearch-users userdel jacknich</pre>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="syskeygen.html">« elasticsearch-syskeygen</a>
</span>
<span class="next">
<a href="how-to.html">How To »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>